<?=form_open_multipart(uri_string(),array('id'=>'category'))?> 
	<input type="hidden" name="catsub" id="catsub" class="w350" value="0">   
    <table class="form">
    	<tr style="display:none;">
            <td class="label" style="width: 150px;">Thuộc chuyên mục</td>
            <td>
                <select id="catsub" name="catsub" class="w350">
                     <option value="0">Là chuyên mục chính</option>
                    <?php echo $category_option ?>
                </select>
            </td>
        </tr> 
        <tr>
            <td class="required label" style="width: 150px;">Ảnh đại diện</td>
            <td><a class="lib_img" href="javascript:imgLib.openLib({width:120,height:120,return_tag:'lb_image',action:'imgcrop'});"></a>
            <div class="lb_image"><input type="hidden" name="lb_image" value="" id="lb_image"></div></td>
        </tr>
        <tr>
            <td class="required label" style="width: 150px;">Category Name</td>
            <td><input type="text" name="catname_vn" id="catname_vn" class="w350" value=""></td>
        </tr> 
        <tr>
            <td class="required label" style="width: 150px;">Category Name</td>
            <td><input type="text" name="catname_en" id="catname_en" class="w350" value=""></td>
        </tr> 
        <tr>
            <td class="label" style="width: 150px;">Thứ tự</td>
            <td><input type="text" name="nb_order" id="nb_order" class="w350" value=""></td>
        </tr>
        <tr>
            <td class="label"><?=lang('status')?></td>
            <td><input type="checkbox" name="bl_active" id="bl_active" checked  value="1"></td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <input type="submit" name="bt_submit" value="" class="themmoi">
            </td>
        </tr>  
    </table>
<?=form_close()?>
<script type="text/javascript">
$(document).ready(function(){
	$("#category").validate({
        rules: {
            catname_vn: "required",
            lb_image:{validateImage :"required"}
        },
        messages: {
			catname_vn: "Vui lòng điền tên Đại Sứ Quán",
			lb_image:{validateImage:"File ảnh không hợp lệ!",}
        }
    });
	
	$.validator.addMethod('validateImage', function() {
		var test_value = $("#lb_image").val();
		if(test_value=='') return false;
        var extension = test_value.split('.').pop().toLowerCase();

        if( $.inArray(extension, ['png', 'gif' ,'jpeg', 'jpg']) == -1 ){
            //alert("File ảnh không hợp lệ!");
            return false;
        }
        else{
            //alert("File ảnh hợp lệ!");
            return true;
        }
	});
});
</script> 